﻿using Bank_database_system.业务部.账户操作;
using Bank_database_system.业务部.贷款业务;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Bank_database_system.业务部
{
    public partial class 业务首页 : Form
    {
        private string branch_id = "";
        private string staff_id = "";
        柜台业务a counter_business = new 柜台业务a();
        贷款业务a loan_business = new 贷款业务a();
        账户操作a account_operations = new 账户操作a();
        int flag = 0;
        public 业务首页()
        {
            InitializeComponent();
            label4.Text = AccountCheck.name;
            label5.Text = AccountCheck.branchname;
            branch_id = AccountCheck.branchid;
            staff_id = label6.Text = AccountCheck.staffid;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label3.Text = "当前时间：" + DateTime.Now.ToString("HH:mm:ss");
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (flag != 3)
            {
                flag = 3;
                // 切换按钮图像
                button2.Image = Properties.Resources.柜台业务;
                button3.Image = Properties.Resources.账户操作;
                button4.Image = Properties.Resources.贷款业务按下;
                //传入支行和员工ID
                loan_business.branch_and_staff_get(branch_id, staff_id);
                //在容器中添加新空间
                panel1.Visible = true;
                panel1.Controls.Clear();
                panel1.Controls.Add(loan_business);
                //清空其它两个面板
                account_operations = new();
                counter_business = new();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (flag != 2)
            {
                flag = 2;
                // 切换按钮图像
                button2.Image = Properties.Resources.柜台业务;
                button3.Image = Properties.Resources.账户操作按下;
                button4.Image = Properties.Resources.贷款业务;
                //传入支行和员工ID
                account_operations.branch_and_staff_get(branch_id, staff_id);
                //在容器中添加新空间
                panel1.Visible = true;
                panel1.Controls.Clear();
                panel1.Controls.Add(account_operations);
                //清空其它两个面板
                loan_business = new();
                counter_business = new();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (flag != 1)
            {
                flag = 1;
                // 切换按钮图像
                button2.Image = Properties.Resources.柜台业务按下;
                button3.Image = Properties.Resources.账户操作;
                button4.Image = Properties.Resources.贷款业务;
                //传入支行和员工ID
                //counter_business.branch_and_staff_get(branch_id, staff_id);
                //在容器中添加新空间
                panel1.Visible = true;
                panel1.Controls.Clear();
                panel1.Controls.Add(counter_business);
                //清空其它两个面板
                loan_business = new();
                account_operations = new();
            }
        }

        private void 业务首页_Load(object sender, EventArgs e)
        {
            // 启动定时器
            timer1.Start();
            label3.Text = "当前时间：" + DateTime.Now.ToString("HH:mm:ss");
        }

        private void button8_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("是否注销当前账号？", "提示", MessageBoxButtons.OKCancel);
            if (dr == DialogResult.OK)
            {
                //将窗体返回结果设置为Cancel,但并不退出系统
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void button2_mouse_enter(object sender, EventArgs e)
        {
            if (flag != 1)
            {
                // 鼠标悬停时更改图片
                button2.Image = Properties.Resources.柜台业务悬停;
            }
        }

        private void button2_mouse_leave(object sender, EventArgs e)
        {
            if (flag != 1)
            {
                // 鼠标悬停时更改图片
                button2.Image = Properties.Resources.柜台业务;
            }
        }

        private void button3_mouse_enter(object sender, EventArgs e)
        {
            if (flag != 2)
            {
                // 鼠标悬停时更改图片
                button3.Image = Properties.Resources.账户操作悬停;
            }
        }

        private void button3_mouse_leave(object sender, EventArgs e)
        {
            if (flag != 2)
            {
                // 鼠标悬停时更改图片
                button3.Image = Properties.Resources.账户操作;
            }
        }
        private void button4_mouse_enter(object sender, EventArgs e)
        {
            if (flag != 3)
            {
                // 鼠标悬停时更改图片
                button4.Image = Properties.Resources.贷款业务悬停;
            }
        }

        private void button4_mouse_leave(object sender, EventArgs e)
        {
            if (flag != 3)
            {
                // 鼠标悬停时更改图片
                button4.Image = Properties.Resources.贷款业务;
            }
        }
    }
}
